package top.abrsm.mapper;

import org.apache.ibatis.annotations.Select;
import top.abrsm.entity.OrderEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * <p>
 * 贴吧订单表：置顶充值、积分充值 Mapper 接口
 * </p>
 *
 * @author WuZH
 * @since 2023-11-18
 */
@Mapper
public interface OrderMapper extends BaseMapper<OrderEntity> {

    @Select ( value = "<script>SELECT * FROM order_info oi LEFT JOIN product_info pi ON oi.productId=pi.id LEFT JOIN student_info si ON oi.stuId=si.id\n" +
            "<trim prefix=\"WHERE\" prefixOverrides=\"and | or\">" +
            "<if test='stuId!=null'> AND oi.stuId=#{stuId} </if>" +
            "<if test='tradeStatus!=null'> AND oi.tradeStatus=#{tradeStatus} </if>" +
            "<if test='type!=null'> AND oi.type=#{type} </if>" +
            "</trim>ORDER BY oi.createTime DESC limit #{limit},#{offset}</script>" )
    List<OrderEntity> queryList ( String stuId, Integer tradeStatus, Integer type, Integer limit, Integer offset );

}
